/**获取当前页面的git参数 

如果url是 http://example.com/?id=123&name=John&name=Mike
则返回
{
  id: "123",
  name: ["John", "Mike"]
}
*/
function getAllQueryStrings() {
    var result = {};
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var i=0; i<vars.length; i++) {
      var pair = vars[i].split("=");
      if (typeof result[pair[0]] === "undefined") {
        result[pair[0]] = decodeURIComponent(pair[1]);
      } else if (typeof result[pair[0]] === "string") {
        var arr = [result[pair[0]], decodeURIComponent(pair[1])];
        result[pair[0]] = arr;
      } else {
        result[pair[0]].push(decodeURIComponent(pair[1]));
      }
    }
    return result;
}

let imgs = document.getElementsByClassName("display-img");
let createMessage = document.getElementById('createMessage');
window.addEventListener('load',e=>{
    let querys = getAllQueryStrings();
    let imgSrcs = querys.imgs;
    let cm = querys.createmessage;
    if(cm){
      createMessage.innerText = cm.replaceAll('+',' ');
    }
    if(imgSrcs){
      if(imgSrcs instanceof Array){
        for(let i=0;i<imgSrcs.length&&i<imgs.length;i++){
            imgs[i].src = imgSrcs[i];
            imgs[i].onclick = ()=>{
              window.open(imgs[i].src, '_blank');
            };
        }
        return;
      }else{
        imgs[0].src = imgSrcs;
      }
    }
});